package com.dev.toolkit.common.exception;

import lombok.Getter;

/**
 * @author ZhuYouBin
 * @version 1.0.0
 * @date 2024/4/6 16:02
 * @description 自定义异常类
 */
@Getter
public class BizException extends RuntimeException {
    /**
     * 状态码
     */
    private Integer code;
    /**
     * 提示信息
     */
    private String message;

    public BizException(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public BizException(int code, String message, Object... args) {
        this.code = code;
        for (Object param : args) {
            message = message.replace("{}", String.valueOf(param));
        }
        this.message = message;
    }

    public BizException() {
        super();
    }

    public BizException(String message) {
        this.message = message;
    }

    public BizException(String message, Object... args) {
        this.message = message;
        for (Object param : args) {
            message = message.replace("{}", String.valueOf(param));
        }
        this.message = message;
    }

    public BizException(String message, Throwable cause) {
        super(message, cause);
    }

    public BizException(Throwable cause) {
        super(cause);
    }

    protected BizException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }
}